package org.minuframework.file.upload;

import java.io.File;

import org.minuframework.lang.StringUtils;
import org.minuframework.utils.ParamUtils;
import org.minuframework.core.ApplicationConfigurer;

@Deprecated
public class DefaultFileBuilder{
    
    protected String                charset;
    protected String                minuConfigurerPathname;
    protected String                mimeTypeConfigurerPathname;
    protected File                  minuConfigurerFile;
    protected File                  mimeTypeConfigurerFile;
    protected FileParamerConfigurer fileParamerConfigurer;
    protected FileTypesConfigurer   fileTypesConfigurer;
    
    public DefaultFileBuilder getParamerRepository(){
        if (fileParamerConfigurer == null) {
            if (minuConfigurerFile == null) {
                if (StringUtils.isEmpty(minuConfigurerPathname)) {
                    this.minuConfigurerPathname = ApplicationConfigurer.getDefaultMINUConfigurerFile();
                }
                String pathname = ParamUtils.getPathName(minuConfigurerPathname);
                this.minuConfigurerFile = new File(pathname);
            }
            this.fileParamerConfigurer = new FileParamerConfigurer(minuConfigurerFile);
        }
        if (fileTypesConfigurer == null) {
            if (mimeTypeConfigurerFile == null) {
                if (StringUtils.isEmpty(mimeTypeConfigurerPathname)) {
                    this.mimeTypeConfigurerPathname = ApplicationConfigurer.getDefaultMIMETypeConfigurerFile();
                }
                String pathname = ParamUtils.getPathName(mimeTypeConfigurerPathname);
                this.mimeTypeConfigurerFile = new File(pathname);
            }
            this.fileTypesConfigurer = new FileTypesConfigurer(mimeTypeConfigurerFile);
        }
        return this;
    }
    
}
